#include <iostream>
#include <mutex>
#include <condition_variable>
#include <thread>
using namespace std;

mutex mtx;
condition_variable cv;
bool ready = false;

void print_id(int id)
{
    unique_lock<mutex> lock(mtx);
    cv.wait(lock, []
            { return ready; });
    cout << "Thread ID:" << id << endl;
}

void set_ready()
{
    unique_lock<mutex> lock(mtx);
    ready = true;
    cv.notify_all();
}

int main()
{
    thread t1(print_id, 1);
    thread t2(print_id, 2);
    this_thread::sleep_for(chrono::seconds(1));
    set_ready();
    t1.join();
    t2.join();
    return 0;
}